package queryTree;

import java.util.ArrayList;

import optimization.Condition;

/**
 * two tables in join operation. 
 * @author Van
 *	
 */
public class TableCouple {
	private String table1;
	private String table2;
	ArrayList<Condition> joinConditionList = new ArrayList<Condition>();
	@Override
	public int hashCode() {		
		return table1.hashCode() + table2.hashCode();
	}
	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o instanceof TableCouple) {
			TableCouple other = (TableCouple) o;			
			return (table1.equals(other.getTable1()) && table2.equals(other.getTable2()))
				   || (table1.equals(other.getTable2()) && table2.equals(other.getTable1()));
		}
		return false;
	}
	public String getTable1() {
		return table1;
	}
	public void setTable1(String table1) {
		this.table1 = table1;
	}
	public String getTable2() {
		return table2;
	}
	public void setTable2(String table2) {
		this.table2 = table2;
	}
	
	protected TableCouple(String table1, String table2) {
		super();
		this.table1 = table1;
		this.table2 = table2;
		joinConditionList = new ArrayList<Condition>();
	}
	public ArrayList<Condition> getJoinConditionList() {
		return joinConditionList;
	}
	public void setJoinConditionList(ArrayList<Condition> joinConditionList) {
		this.joinConditionList = joinConditionList;
	}
	
	public void addCondition(Condition joinCondition) {
		joinConditionList.add(joinCondition);
	}
	
}
